{template '_header'}
<div class="page-header">

    当前位置：<span class="text-primary"> {if !empty($item['id'])}编辑{else}添加{/if}发放任务</span>

</div>
<div class="page-content">
    {ifp 'sale.coupon'}
    <div class="page-sub-toolbar">
            <a class='btn btn-primary btn-sm' href="{php echo webUrl('sale/coupon/sendtask/add')}"><i class='fa fa-plus'></i> 添加任务</a>
    </div>
    {/if}
<form {ife 'sale.coupon' $item}action="" method="post"{/if} class="form-horizontal form-validate" enctype="multipart/form-data">
    <input type="hidden" name="id" value="{$item['id']}" />
        <div class="tab-content ">
            <div class="tab-pane active">
                <div class="panel-body">

                    <div class="form-group ">
                        <label class="col-lg control-label must">满足价格</label>
                        <div class="col-sm-9 col-xs-12">
                            {ife 'sale.coupon' $item}
                            <div class="input-group">
                                <input type='text' class='form-control' name='enough' value="{$item['enough']}"/>
                                <span class="input-group-addon">元</span>
                            </div>
                            <span class="help-block image-block" style="display: block;">当订单金额达到此金额要求时,触发发送优惠券任务</span>
                            {else}
                            <div class='form-control-static'>{$item['price']}</div>
                            {/if}
                        </div>
                    </div>

                    <div class="form-group">
                        {ife 'sale.coupon' $item}
                                <label class="col-lg control-label">选择优惠券</label>
                                <div class="col-sm-9 col-xs-12">
                                        <?php echo tpl_selector('couponid',array(
                                        'preview'=>true,
                                        'readonly'=>true,
                                        'multi'=>0,
                                        'value'=>$item['title'],
                                        'url'=>webUrl('sale/coupon/querycoupons'),
                                        'items'=>$coupon,
                                        'buttontext'=>'选择优惠券',
                                        'placeholder'=>'请选择优惠券')
                                        )
                                        ?>
                            </div>
                        {else}
                            {if !empty($coupon)}
                                <a href="{php echo tomedia($coupon['thumb'])}" target='_blank'>
                                    <img src="{php echo tomedia($coupon['thumb'])}" style='width:100px;border:1px solid #ccc;padding:1px' />
                                </a>
                            {else}
                            暂无商品
                            {/if}
                        {/if}
                    </div>

                    <div class="form-group ">
                        <label class="col-lg control-label must">发送数量</label>
                        <div class="col-sm-9 col-xs-12">
                            {ife 'sale.coupon' $item}
                            <div class="input-group col-lg">
                                <select class='form-control '  id="sendnum" name="sendnum" >
                                    <option value="1" {if $item['sendnum']=='1'} selected{/if}>1</option>
                                    <option value="2" {if $item['sendnum']=='2'} selected{/if}>2</option>
                                    <option value="3" {if $item['sendnum']=='3'} selected{/if}>3</option>
                                    <option value="4" {if $item['sendnum']=='4'} selected{/if}>4</option>
                                    <option value="5" {if $item['sendnum']=='5'} selected{/if}>5</option>
                                </select>
                                <span class="input-group-addon">张</span>
                            </div>
                            <span class="help-block image-block" style="display: block;">当用户购买此商品时,赠送几张指定的优惠券</span>
                            {else}
                            <div class='form-control-static'>{$item['sendnum']}</div>
                            {/if}
                        </div>
                    </div>

                    <div class="form-group ">
                        <label class="col-lg control-label must">剩余数量</label>
                        <div class="col-sm-9 col-xs-12">
                            {ife 'sale.coupon' $item}
                            <div class="input-group">
                                <input type='text' class='form-control' name='num' value="{$item['num']}" />
                                <span class="input-group-addon">张</span>
                            </div>
                            <span class="help-block image-block" style="display: block;">当剩余数量小于发送数量时,发送任务停止</span>
                            {else}
                            <div class='form-control-static'>{$item['num']}</div>
                            {/if}
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg control-label">限时设置</label>
                        <div class="col-sm-9 col-xs-12">
                            {ife 'sale.package' $item}
                            <div class="input-group">
                                {php echo tpl_form_field_daterange('sendtime', array('starttime'=>date('Y-m-d', intval($item['starttime'])),'endtime'=>date('Y-m-d', intval($item['endtime']))));}

                            </div>
                            {else}
                            <div class='form-control-static'>{php echo date('Y-m-d H',$item['starttime'])} - {php echo date('Y-m-d H',$item['endtime'])}</div>
                            {/if}
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg control-label must">发送节点</label>
                        <div class="col-xs-12 col-sm-8">
                            <div class="input-group">
                                {ife 'sale.coupon' $item}
                                <label class="radio radio-inline">
                                    <input type="radio" name="sendpoint" value="1" {if intval($item['sendpoint']) ==1 }checked="checked"{/if}> (推荐)订单完成后（包括子订单内所有订单收货后）发送优惠券
                                </label>
                                <label class="radio radio-inline">
                                    <input type="radio" name="sendpoint" value="2" {if intval($item['sendpoint']) ==2 }checked="checked"{/if}> 订单付款后发送优惠券
                                </label>
                                {else}
                                <div class='form-control-static'>{if intval($item['sendpoint']) ==1 }(推荐)订单完成后（包括子订单内所有订单收货后）发送优惠券{else if intval($item['sendpoint']) ==2}订单付款后发送优惠券{/if}</div>
                                {/if}
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg control-label must">状态</label>
                        <div class="col-xs-12 col-sm-8">
                            <div class="input-group">
                                {ife 'sale.coupon' $item}
                                <label class="radio radio-inline">
                                    <input type="radio" name="status" value="1" {if intval($item['status']) ==1 }checked="checked"{/if}> 开启
                                </label>
                                <label class="radio radio-inline">
                                    <input type="radio" name="status" value="0" {if intval($item['status']) ==0}checked="checked"{/if}> 关闭
                                </label>
                                {else}
                                <div class='form-control-static'>{if intval($item['status']) ==1 }开启{else}关闭{/if}</div>
                                {/if}
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
        {ife 'sale.coupon' $item}
        <div class="form-group">
            <label class="col-lg control-label"></label>
            <div class="col-sm-9 col-xs-12">
                <input type="submit"  value="提交" class="btn btn-primary" />
                <a class="btn btn-default" href="{php echo webUrl('sale/coupon/sendtask')}">返回列表</a>
            </div>
        </div>
        {/if}
</form>
</div>

{template '_footer'}